1. Field of the Invention
The present invention relates to the art of information processing. It finds particular application in Java programming for resolving memory leaks due to failures of the automatic memory management system, and will be described with particular reference thereto. However, the present invention is useful in many other programming environments that employ automatic memory management, such as the C# programming environment.
2. Description of Related Art
A feature of Java, C#, and certain other programming environments is automatic memory management, in which one or more garbage collector algorithms are provided to automatically remove objects that are no longer in use. Programming environments with automatic memory management are less susceptible to memory leaks introduced by failure of programmers to remove unneeded objects in a timely manner.
Even with automatic memory management, however, memory leaks can arise due to various failures of the automatic memory management. In one common situation, a programmer fails to properly dereference one or more system resource references, such as file handles, database connections, sockets, threads, or the like. This leads to objects containing obsolete references that inhibit or prevent their removal by the garbage collector. Moreover, in addition to not collecting the object containing the obsolete references, the garbage collector will be inhibited or prevented from collecting any objects referenced by the object containing these obsolete references. In this way, a few obsolete references can lead to a large number of uncollected objects.
Memory leakage is a general problem that can affect any type of computer program; however, memory leaks are particularly problematic in certain programming applications where such leaks can accumulate over time to reduce the available free memory. For example, in a server application, a separate user session is opened for each user who accesses the server. The user session expires when the user logs out, closes the browser, or otherwise disengages from the server. When the session expires, the user session objects should be collected by the garbage collector to free up memory. Objects containing obsolete references may not be collected, however, and can accumulate over time as users successively log onto and disconnect from the server. Eventually, such accumulated memory leaks lead to a server crash as the available memory becomes filled.
The present invention contemplates an improved method and apparatus which overcomes these limitations and others.